package com.wanmait.shoppingsys.util;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

public class ManagePager {
	private List data;//本页数据
	private int pageNum;//当前页码
	private int rowCount;//记录个数
	private int pageSize = 10;//每页多少条记录
	
	private Integer typeId;
	private Integer cityId;
	private Integer specialtyId;

	private Integer goodsId;
	private Integer userinfoId;

	private String goodsNum;    //订单号  或者   商品关键字   或者用户名
	

	
	public boolean hasPrev() {
		return pageNum>1;
	}
	public boolean hasNext() {
		return pageNum<this.getPageCount();
	}

	
	public static ManagePager init(HttpServletRequest request) {           //查询
		String goodsNum = request.getParameter("name"); 
		String pageNumStr = request.getParameter("pageNum");
		String pageSizeStr = request.getParameter("pageSize");
		int  pageNum = 1;
		try {
			pageNum = Integer.parseInt(pageNumStr);
		} catch (NumberFormatException e) {
		}
		int pageSize = 10;
		try {
			pageSize = Integer.parseInt(pageSizeStr);
		} catch (NumberFormatException e) {
		}
		ManagePager managepager = new ManagePager();
		managepager.setPageNum(pageNum);
		managepager.setPageSize(pageSize);
		managepager.setGoodsNum(goodsNum);
		
		
		request.setAttribute("managerpager", managepager);
		return managepager;
	}
	
	
	
	
	public static ManagePager inot(HttpServletRequest request) {      //类型
		String pageNumStr = request.getParameter("pageNum");
		String pageSizeStr = request.getParameter("pageSize");
		String typeIdStr=request.getParameter("typeId");
		 
		 Integer typeId=Integer.parseInt(typeIdStr);
		int  pageNum = 1;
		try {
			pageNum = Integer.parseInt(pageNumStr);
		} catch (NumberFormatException e) {
		}
		
		int pageSize = 10;
		try {
			pageSize = Integer.parseInt(pageSizeStr);
		} catch (NumberFormatException e) {
		}
		ManagePager managepager = new ManagePager();
		managepager.setPageNum(pageNum);
		managepager.setPageSize(pageSize);
		managepager.setTypeId(typeId);
		request.setAttribute("managerpager", managepager);
		return managepager;
	}
	
	
	public static ManagePager inat(HttpServletRequest request) {      //城市
		String pageNumStr = request.getParameter("pageNum");
		String pageSizeStr = request.getParameter("pageSize");
		String cityIdStr=request.getParameter("cityId");
		 Integer cityId=Integer.parseInt(cityIdStr);
		int  pageNum = 1;
		try {
			pageNum = Integer.parseInt(pageNumStr);
		} catch (NumberFormatException e) {
		}
		
		int pageSize = 10;
		try {
			pageSize = Integer.parseInt(pageSizeStr);
		} catch (NumberFormatException e) {
		}
		ManagePager managepager = new ManagePager();
		managepager.setPageNum(pageNum);
		managepager.setPageSize(pageSize);
		managepager.setCityId(cityId);
		request.setAttribute("managerpager", managepager);
		return managepager;
	}
	
	
	public static ManagePager indt(HttpServletRequest request) {      //物品
		String pageNumStr = request.getParameter("pageNum");
		String pageSizeStr = request.getParameter("pageSize");
		String specialtyIdStr=request.getParameter("specialtyId");
		Integer specialtyId=Integer.parseInt(specialtyIdStr);
		int  pageNum = 1;
		try {
			pageNum = Integer.parseInt(pageNumStr);
		} catch (NumberFormatException e) {
		}
		
		int pageSize = 10;
		try {
			pageSize = Integer.parseInt(pageSizeStr);
		} catch (NumberFormatException e) {
		}
		
		ManagePager managepager = new ManagePager();
		managepager.setPageNum(pageNum);
		managepager.setPageSize(pageSize);
		managepager.setSpecialtyId(specialtyId);
		request.setAttribute("managerpager", managepager);
		return managepager;
	}
	
	
	
	

	public static ManagePager inpt(HttpServletRequest request) {      //订单
		String pageNumStr = request.getParameter("pageNum");
		String pageSizeStr = request.getParameter("pageSize");
		String goodsIdStr=request.getParameter("goodsId");
		Integer goodsId=Integer.parseInt(goodsIdStr);
		int  pageNum = 1;
		try {
			pageNum = Integer.parseInt(pageNumStr);
		} catch (NumberFormatException e) {
		}
		
		int pageSize = 10;
		try {
			pageSize = Integer.parseInt(pageSizeStr);
		} catch (NumberFormatException e) {
		}
		
		ManagePager managepager = new ManagePager();
		managepager.setPageNum(pageNum);
		managepager.setPageSize(pageSize);
		managepager.setSpecialtyId(goodsId);
		request.setAttribute("managerpager", managepager);
		return managepager;
	}
	
	
	
	public static ManagePager inut(HttpServletRequest request) {      //用户
		String pageNumStr = request.getParameter("pageNum");
		String pageSizeStr = request.getParameter("pageSize");
		String userinfoIdStr=request.getParameter("userinfoId");
		Integer userinfoId=Integer.parseInt(userinfoIdStr);
		int  pageNum = 1;
		try {
			pageNum = Integer.parseInt(pageNumStr);
		} catch (NumberFormatException e) {
		}
		
		int pageSize = 10;
		try {
			pageSize = Integer.parseInt(pageSizeStr);
		} catch (NumberFormatException e) {
		}
		
		ManagePager managepager = new ManagePager();
		managepager.setPageNum(pageNum);
		managepager.setPageSize(pageSize);
		managepager.setSpecialtyId(userinfoId);
		request.setAttribute("managerpager", managepager);
		return managepager;
	}
	
	
	
	
	
	public Integer getUserinfoId() {
		return userinfoId;
	}
	public void setUserinfoId(Integer userinfoId) {
		this.userinfoId = userinfoId;
	}
	public Integer getGoodsId() {
		return goodsId;
	}
	public void setGoodsId(Integer goodsId) {
		this.goodsId = goodsId;
	}

	public int getPageCount() {
		if(rowCount<0) return 1;
		return rowCount/pageSize+(rowCount%pageSize==0?0:1);
	}
	public List getData() {
		return data;
	}
	public void setData(List data) {
		this.data = data;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getRowCount() {
		return rowCount;
	}
	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	
	public Integer getTypeId() {
		return typeId;
	}
	public void setTypeId(Integer typeId) {
		this.typeId = typeId;
	}
	public Integer getCityId() {
		return cityId;
	}
	public void setCityId(Integer cityId) {
		this.cityId = cityId;
	}
	public Integer getSpecialtyId() {
		return specialtyId;
	}
	public void setSpecialtyId(Integer specialtyId) {
		this.specialtyId = specialtyId;
	}
	public String getGoodsNum() {
		return goodsNum;
	}
	public void setGoodsNum(String goodsNum) {
		this.goodsNum = goodsNum;
	}
}
